<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ page import="com.scalar.chiptrack.utils.ConfigManager" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/customerReport.do?action=pendingShipment"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%><%-- try {--%> 
<%
    String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
    String userTypeVendor = Constants.USER_TYPE_VENDOR + "";
    String userTypeSalesPerson = Constants.USER_TYPE_SALES_PERSON + "";
%>
<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>
</HEAD>
<script language="javascript">

    var dateElement = "";
    function openCalendar(dateValue)
    {
        dateElement = dateValue;
        newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
        newWindow.moveTo(550,180);
        newWindow.focus();
    }

    function assignDate(passedValue)
    {
        dateElement.value=passedValue;
        window.focus();
    }

    function submitReport( fileType )
    {
        var d = new Date();
        var day = d.getDate();
        var month = d.getMonth()+1;
        var year = d.getFullYear();
        var hour = d.getHours();
        var min = d.getMinutes();
        var sec = d.getSeconds();
        var pa	= document.getElementById("message")
        var defaultPrompt = day+"/"+month+"/"+year+":"+hour+":"+min+":"+sec;
        var success;
        var formdoc = document.customerReportForm

        success = true;
        if( success == false )
        {
            pa.innerHTML = errMsg;
            return;
        }

        var partNumberObj = formdoc.productId;
        var processstepId = "";
        var count = 0;
        for( var i = 0; i < partNumberObj.length; i++ )
        {
            if( partNumberObj.options[i].selected )
            {
                count++;
                if ( processstepId != '' )
                {
                    processstepId = processstepId + "," + partNumberObj.options[i].value;
                }
                else
                {
                    processstepId = partNumberObj.options[i].value;
                    if( partNumberObj.options[i].value == '0' )
                    {
                        break;
                    }
                }
            }
        }
        if ( processstepId == '')
        {
            processstepId = "0";
        }
        if( count > 10)
        {
            pa.innerHTML = "<li>Please select upto 10 Products only";
            return;
        }
        else
        {
            formdoc.prompt1.value = processstepId;
        }

        var customerObj = formdoc.customer;
        var customerId = "";
        var counter = 0;
        for( var i = 0; i < customerObj.length; i++ )
        {
            if( customerObj.options[i].selected )
            {
                count++;
                if ( customerId != '' )
                {
                    customerId = customerId + "," + customerObj.options[i].value;
                }
                else
                {
                    customerId = customerObj.options[i].value;
                    if( customerObj.options[i].value == '0' )
                    {
                        break;
                    }
                }
            }
        }
        if ( customerId == '')
        {
            customerId = "0";
        }
        if( counter > 10)
        {
            pa.innerHTML = "<li>Please select upto 10 Customers only";
            return;
        }
        else
        {
            formdoc.prompt0.value = customerId;
        }

        <logic:equal value="<%=userTypeSalesPerson%>" name="user" property="userType" scope="session">
        if  ( formdoc.prompt0.value== 0 )
        {
            var element = formdoc.customer;
            var customerIds = "0";
            for( var i = 0 ; i < element.length; i++ )
            {
                if ( customerIds != '' && customerIds != "0" )
                {
                    customerIds = customerIds+","+element.options[i].value;
                }
                else
                {
                    customerIds = element.options[i].value;
                }
            }

            formdoc.prompt0.value= customerIds;
        }
        </logic:equal>

        if ( formdoc.soNumber.value == '' )
        {
            formdoc.prompt2.value = '0';
        }
        else
        {
            formdoc.prompt2.value = formdoc.soNumber.value;
        }
        
        formdoc.prompt3.value = formdoc.category.value;
        formdoc.prompt4.value = formdoc.daterange.value;
        formdoc.prompt5.value = "crystal";

        if ( formdoc.vendor.value == '' )
        {
            formdoc.prompt6.value = '0';
        }
        else
        {
            formdoc.prompt6.value = formdoc.vendor.value;
        }

        <%--<logic:equal value="<%=userTypeVendor%>" name="user" property="userType" scope="session">
        formdoc.prompt6.value = formdoc.vendorId.value;
        </logic:equal>--%>
        formdoc.prompt7.value = defaultPrompt;
        formdoc.prompt8.value = '';
        formdoc.prompt9.value = '';

        if( fileType == 2 )
        {
            var prompt0 = formdoc.prompt0.value;
            var prompt1 = formdoc.prompt1.value;
            var prompt2 = formdoc.prompt2.value;
            var prompt3 = formdoc.prompt3.value;
            var prompt4 = formdoc.prompt4.value;
            var prompt5 = "xlreport";
            var prompt6 = formdoc.prompt6.value;
            var prompt7 = defaultPrompt;

            var newWindow;
            var url = '<%=chipTracContext%>/customerReport.do?action=pendingShipmentxls&popUp=true&prompt0=' + prompt0 + '&prompt1=' + prompt1 + '&prompt2=' + prompt2 + '&prompt3=' + prompt3 + '&prompt4=' + prompt4 + '&prompt5=' + prompt5 + '&prompt6=' + prompt6;
            newWindow = window.open ( url, 'PendingShipmentReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');
        }
        else
        {
            formdoc.action="<%=chipTracContext%>/jsp/report.jsp?nameReport=Sales/Shipped/Pending_Shipment_Report.rpt";
            formdoc.submit();
            return true;
        }
}

</script>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" >
<!-- Top Header Start-->

    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/header.jsp" %>
    </logic:equal>
    <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
        <%@ include file="/jsp/includes/extHeader.jsp" %>
    </logic:notEqual>

<!-- Top Header End-->
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
    <!-- Side Navigation start -->
    <%--<%@ include file="/jsp/sales/sales_report_menu.jsp" %>--%>
        <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/sales_report_menu.jsp" %>
        </logic:equal>
        <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/external_reports_menu.jsp" %>
        </logic:notEqual>
    <!-- end of the side navigations -->
    </TD>
    <TD bgcolor="#ffffff">
        <IMG height="9" src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="8"></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="2"></TD>
        <TD valign="top" width="100%">
        <IMG height="1" src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width="500" border="0">
        <BR>
        <html:form name="customerReportForm" type="com.scalar.chiptrack.sales.reports.forms.CustomerReportForm" action="/customerReport">
        <TABLE border="0" width="100%" align="center">
            <TR><TD colspan="7" class="NArialW" align="center">Pending Shipment Report</TD></TR>
            <TR>
                <TD colspan="7">
                    <input type="hidden" name="prompt0">
                    <input type="hidden" name="prompt1">
                    <input type="hidden" name="prompt2">
                    <input type="hidden" name="prompt3">
                    <input type="hidden" name="prompt4">
                    <input type="hidden" name="prompt5">
                    <input type="hidden" name="prompt6">
                    <input type="hidden" name="prompt7">
                    <input type="hidden" name="prompt8">
                    <input type="hidden" name="prompt9">
                    <%--<input type="hidden" name="vendorId" value = '<bean:write name="user" property="vendorId" />' >--%>
                </TD>
            </TR>
            <%--<TR><TD colspan="7">&nbsp;</TD></TR>--%>
            <TR><TD width="12%" >&nbsp;</TD><TD colspan="7" class='NArialL' align="left"><strong><FONT id="message" styleClass="NArialL" color='FF0000'>&nbsp;</FONT></strong></TD></TR>
            <TR>
                <TD>&nbsp;</TD>
                <TD colspan="7" align="left">
                  <chiptrack:info styleClass="NArialL" />
                  <chiptrack:errors styleClass="NArialL" />
                  <chiptrack:messages type="info" styleClass="NArialL" />&nbsp;
                </TD>
            </TR>
            <TR>
                    <TR>
                        <TD width="10%" >&nbsp;</TD>
                        <TD width="15%" class="NArialL" valign = 'top' >Customer :</TD>
                        <TD width="20%" class="NArialL" valign = 'top'>
                            <html:select property="customer" name="customerReportForm" styleClass="txfield" style="width:180px" multiple="true" size="5">
                                <html:options collection="customerList" property="value" labelProperty="label"/>
                            </html:select>
                        </TD>
                        <TD width="5%" >&nbsp;</TD>
                        <TD width="15%" class="NArialL" valign = 'top'>Part Number :</TD>
                        <TD width="20%" class="NArialL" valign = 'top'>
                            <html:select property="productId" name="customerReportForm" styleClass="txfield" style="width:180px" multiple = "true" size = "5">
                                <html:option value="-1">All Products</html:option>
                                <html:options collection="mktgPartNumberSelectList" property="value" labelProperty="label"/>
                            </html:select>
                        </TD>
                        <TD width="10%">&nbsp;</TD>
                    </TR>
                    <TR><TD colspan="7"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=8></TD></TR>
                    <TR>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="17%" class="NArialL" valign="top">Sales Order No :</TD>
                            <TD width="20%" class="NArialL">
                                <html:text property="soNumber" name="customerReportForm" styleClass="txfield" style="width:180px"/>
                            </TD>
                            <TD width="5%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign="top" >Category :</TD>
                            <TD width="20%" class="NArialL" valign="top">
                                <html:select property="category" styleClass="txfield" style="width:180px" >
                                    <html:option value="1">Regular</html:option>
                                    <html:option value="0">Sample</html:option>
                                </html:select>
                            </TD>
                            <TD width="10%">&nbsp;</TD>
                        </TR>
                        <TR><TD colspan="7"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=8></TD></TR>
                        <TR>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign="top">Scheduled In :</TD>
                            <TD width="20%" class="NArialL" nowrap>
                                   <html:select property="daterange" styleClass="txfield" style="width:150px" >
                                    <html:option value="1">1</html:option>
                                    <html:option value="2">2</html:option>
                                    <html:option value="3">3</html:option>
                                    <html:option value="4">4</html:option>
                                    <html:option value="5">5</html:option>
                                    <html:option value="6">6</html:option>
                                    <html:option value="7">7</html:option>
                                    <html:option value="8">8</html:option>
                                    <html:option value="9">9</html:option>
                                    <html:option value="10">10</html:option>
                                    <html:option value="11">11</html:option>
                                    <html:option value="12">12</html:option>
                                    <html:option value="13">13</html:option>
                                    <html:option value="14">14</html:option>
                                    <html:option value="15">15</html:option>
                                    <html:option value="16">16</html:option>
                                    <html:option value="17">17</html:option>
                                    <html:option value="18">18</html:option>
                                    <html:option value="19">19</html:option>
                                    <html:option value="20">20</html:option>
                                    <html:option value="21">21</html:option>
                                    <html:option value="22">22</html:option>
                                    <html:option value="23">23</html:option>
                                    <html:option value="24">24</html:option>
                                    <html:option value="25">25</html:option>
                                    <html:option value="26">26</html:option>
                                    <html:option value="27">27</html:option>
                                    <html:option value="28">28</html:option>
                                    <html:option value="29">29</html:option>
                                    <html:option value="30">30</html:option>
                                </html:select> Days
                            </TD>
                            <TD width="5%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign="top" >Vendor :</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <html:select property="vendor" name="customerReportForm" styleClass="txfield" style="width:180px">
                                    <html:options collection="vendorList" property="value" labelProperty="label"/>
                                </html:select>
                            </TD>
                            <TD width="10%">&nbsp;</TD>
                        </TR>
                        <TR><TD colspan="7"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=8></TD></TR>
                        <TR>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="15%">&nbsp;</TD>
                            <TD width="20%">&nbsp;</TD>
                            <TD width="5%">&nbsp;</TD>
                            <TD width="15%">&nbsp;</TD>
                            <td width="20%" valign="top">
                                <a class="NArialL" href="javascript:submitReport(2)" onMouseOver="window.status='Click here to Export to Excel';return true" onMouseOut="window.status='';return true" title='Click here to Export to Excel' >Export to Excel</a>
                            </td>
                            <TD width="10%">&nbsp;</TD>
                        </TR>
                        <TR><TD colspan="7"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></TD></TR>
                        <TR>
                            <TD colspan="7" align=center>
                                <a href="javascript:submitReport(1);"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Pending Shipment Report';return true" onmouseout="window.status='';return true" title='Click to Generate Pending Shipment Report'></a>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <a href="javascript:document.customerReportForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to reset search';return true" onmouseout="window.status='';return true" title="Click here to reset search"></a>
                            </TD>
                        </TR>
                        <TR><TD colspan="7"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></TD></TR>
                    </TABLE>
                </TD>
            </TR>
        </TABLE>
        </html:form>
    </TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
<%--<% } catch(Exception e){e.printStackTrace();} %>--%>
